package cn.fbs.controller;

import cn.fbs.service.CheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @author 安逸
 * @date 2021/1/26 - 15:16
 **/
@Api(tags = "审查评论")
@RestController
@RequestMapping("check")
public class CheckController {
    @Autowired
    private CheckService checkService;

    @ApiOperation("查询资料图片视频审查内容")
    @GetMapping("/querydataInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "id",required = true),
            @ApiImplicitParam(name = "connectionType",value = "1是资料2是图片3是视频",required = true)
    })
    public ResponseEntity<Map> querydataInfo(String id, int connectionType){
        return ResponseEntity.ok(checkService.querydataInfo(id,connectionType));
    }

    @ApiOperation("资料图片视频审核")
    @GetMapping("/updatedataInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fileName",value = "文件名",required = false),
            @ApiImplicitParam(name = "source",value = "来源",required = false),
            @ApiImplicitParam(name = "fileSize",value = "文件大小",required = false),
            @ApiImplicitParam(name = "id",value = "id",required = true),
            @ApiImplicitParam(name = "categoryId",value = "变更后的标签ID",required = false),
            @ApiImplicitParam(name = "userId",value = "用户名",required = true),
            @ApiImplicitParam(name = "connectionType",value = "文件类型1是资料2是图片3是视频",required = false)
    })
    public ResponseEntity<Map> updateDataInfo(String fileName,String source,String fileSize,String id,String categoryId,String userId,int connectionType){
        return ResponseEntity.ok(checkService.updatedataInfo(fileName,source,fileSize,id,categoryId,userId,connectionType));
    }

    @ApiOperation("资料图片视频评价")
    @GetMapping("/savedatatEvaluate")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "id",required = true),
            @ApiImplicitParam(name = "score",value = "评分（五星）",required = true),
            @ApiImplicitParam(name = "evaluate",value = "评价内容",required = true),
            @ApiImplicitParam(name = "connectionType",value = "关联类型1是资料 2是图片 3是视频",required = true),
            @ApiImplicitParam(name = "userId",value = "用户ID",required = true)
    })
    public ResponseEntity<Map> savedatatEvaluate(String id,String score,String evaluate,int connectionType,String userId){
        return ResponseEntity.ok(checkService.savedatatEvaluate(id,score,evaluate,connectionType,userId));
    }

    @ApiOperation("上传文件")
    @PostMapping("/upload")
    public ResponseEntity<String> uploadFile(MultipartFile file){
        return ResponseEntity.ok(checkService.uploadFile(file));
    }

}
